/**
 * 
 */
package com.wy2.eclipse.tool.ui.resource;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import com.wy2.core.bundle.XmlControl;

/**
 * 从bundle资源中读取 message信息
 * @author nnsword
 * @date 2017-12-10 22:39:44
 *
 */
public final class Messages {

	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BundleConsts.BUNDLE_MESSAGE,Locale.getDefault(), new XmlControl());
	
	
	private Messages() {
    }

    public static String getString(String key) {
        try {
            return RESOURCE_BUNDLE.getString(key);
        } catch (MissingResourceException e) {
            return '!' + key + '!';
        }
    }

    public static String getString(String key, Object...parms) {
        try {
            return MessageFormat.format(RESOURCE_BUNDLE.getString(key), parms);
        } catch (MissingResourceException e) {
            return '!' + key + '!';
        }
    }
}
